<?php
class EditFrag extends Action {
	/*
	 * (non-PHPdoc) @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$data = array ();		
		$fid = irqst ( 'fid' );
		$fragM = new WebFragmentModel ();
		if (empty ( $fid )) {
			$data ['page_tip_info'] = "<strong>出错啦!</strong>fragment_id为空，系统无法加载对应代码片断。";
		} else {
			$fragment = sess_del ( 'fragment_form_data', false );
			if (! $fragment) {
				$fragment = $fragM->read ( $fid );
			}
			if ($fragment == false) {
				$data ['page_tip_info'] = "<strong>出错啦!</strong>fragment_id为{$fid}的代码片断不存在。";
			} else {
				$fragment ['fragment'] = htmlspecialchars_decode ( $fragment ['fragment'] ); // 解码
				$data = $fragment;
				$data ['page_tip_info'] = sess_del ( 'page_tip_info' );
			}
		}
		$suc = irqst ( 'suc' );
		$data ['alert_cls'] = $suc ? 'alert-success' : 'alert-error';
		$data ['editing'] = 1;
		$data ['navi_active'] = '<i class="icon-edit"></i>代码片断';
		return new SmartyView ( $data, 'fragment/FragmentForm' );
	}
}